﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ReservaVueloBO.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "ADMINISTRACIÓN DE RESERVAS Y EMISIÓN DE BOLETOS ELECTRÓNICOS";

            return View();
        } 

        public ActionResult About() 
        {
            return View();
        }

        [HttpPost]
        public ActionResult Buscar_Reserva(Models.BusquedaReserva pObjModel)
        {
            ReservaWS.RVReservaClient objRVReservaClient = new ReservaWS.RVReservaClient();
            List<ReservaWS.Reserva> lstReservas = objRVReservaClient.ListarReserva(pObjModel.FecIni, pObjModel.FecFin, pObjModel.IdEstado.ToString(), pObjModel.CodigoReservas).ToList();
            ViewBag.ListaReservas = lstReservas;
            return View();
        }

        [HttpGet]
        public ActionResult Buscar_Reserva()
        {
            return View();
        }


        public ActionResult LogOn()
        {
            return View();
        }

        public ActionResult LogOut()
        {
            Session["USUARIO"] = null;
            return View("/Views/Home/Index.cshtml");
        }

        public ActionResult Reserva(String pIntIdReserva)
        {
            ReservaWS.RVReservaClient objRVReservaClient = new ReservaWS.RVReservaClient();
            ReservaWS.Reserva objReserva = objRVReservaClient.BuscarReserva(int.Parse(pIntIdReserva));
            ViewBag.Reserva = objReserva;
            return View();
        }

        public ActionResult Emitir_Reserva(FormCollection pObjFormCollection)
        {
            ReservaWS.RVReservaClient objRVReservaClient = new ReservaWS.RVReservaClient();
            objRVReservaClient.EmitirReserva(int.Parse(pObjFormCollection[0]));
            return RedirectToAction("Reserva", new { pIntIdReserva = pObjFormCollection[0] });
        }

    }
}
